﻿using BasicInformation.API.Application.Command.FuelCostsCommand;
using BasicInformation.Infrastructure.Interface;
using MediatR;

namespace BasicInformation.API.Application.CommandHandler.FuelCostsCommandHandler
{
    public class FuelCostsDeleteCommandHandler : IRequestHandler<FuelCostsDeleteCommand, int>
    {
        private readonly IFuelCostsRepository fuelCostsRepository;

        public FuelCostsDeleteCommandHandler(IFuelCostsRepository fuelCostsRepository)
        {
            this.fuelCostsRepository = fuelCostsRepository;
        }
        public async Task<int> Handle(FuelCostsDeleteCommand request, CancellationToken cancellationToken)
        {
            var info = await fuelCostsRepository.Get(request.Id);
            info.IsDel = true;
            return  await fuelCostsRepository.Update(info);
        }
    }
}
